I worked on three main projects this week:
By the next milestone, I hope to have these visualizations finished, and to have the “presentation” of my aggregate and case study data completed. More broadly, I want to incorporate a statistical component into my project. I have not taken any statistics courses, so I would love to talk with you about potential options for trying to perform causal inference related to the propensity for water conflict in river basins.
Like last week, I set “echo = TRUE” for this milestone, to allow for easier review of my code.
In recent years, journalists, policymakers, and academics have become increasingly worried about the potential for climate-induced water scarcity to cause international conflict. Approximately 1.2 billion people live in water-scarce areas worldwide, and this number is expected to increase significantly under the stress of climate change. Some academics have suggested that countries will turn to violent conflict as they attempt to preserve precious transboundary water supplies. Others, led by Elinor Ostrom, winner of the Nobel Prize in Economics, have suggested that increased scarcity will motivate states to cooperate with one another as they attempt to collectively govern shared waters.
While many academics have conducted in-depth qualitative case studies of water governance in transboundary river basins—including the Jordan River, Nile River, and Indus River—few quantitative studies have examined the effect of resource scarcity on water conflict. This project aims to fill that research gap using newly-released datasets covering water governance outcomes over the past 200 years. In so doing, it seeks to answer the following question: Is water scarcity correlated with cooperation or conflict between states?
This project’s GitHub repository lives here.
This project draws heavily on the following datasets from the Oregon State University Program in Water Conflict Management and Transformation:
This research also uses data from the World Bank, accessed using the wbstats() package in R.
We begin by exploring the broad spatial trends that define water conflict. The interactive map below includes five layers (which can be toggled using the “layers” button in the top right corner):
In the future, I will also map the following variables:
################# Preparing Data for Mapping #################
# Created a tibble with a list of events. I chose to filter for strings that
# include words related to conflict. I need to refine my filtering approach, but
# using these four terms works as an initial proxy for my demo case. To be able
# to merge this data with my polygons, I produced a per-basin count of
# conflict-related events.
events_n <- joined %>%
filter(str_detect(event_summary, c("conflict", "war", "violence", "military"))) %>%
distinct(date, .keep_all = TRUE) %>%
group_by(basin_name) %>%
rename(NAME = basin_name) %>%
count() %>%
rename(num_events = n)
# Same approach, for treaties.
treaties_n <- joined %>%
distinct(document_name, .keep_all = TRUE) %>%
group_by(basin_name) %>%
rename(NAME = basin_name) %>%
count() %>%
rename(num_treaties = n)
# Same approach, for organizations. R is throwing a weird error when I try to
# plot this data, so I commented it out for now.
# orgs_n <- joined %>%
# distinct(rbo_name, .keep_all = TRUE) %>%
# group_by(rbo_name) %>%
# rename(NAME = rbo_name) %>%
# count() %>%
# rename(num_orgs = n)
# It would be best to derive gdp, population, and trade from my "joined"
# dataset, and allow the user to select a year to see these variables, in
# addition to the organizations, treaties, and conflicts present in that year.
# Once I have Shiny set up, I think I will be able to do that. For now, I just
# displayed the most recently-available GDP from the World Bank dataset (2015).
gdp_mapping <- gdp %>%
filter(date == 2015) %>%
rename(CNTRY_NAME = country_name)
pop_mapping <- pop %>%
filter(date == 2015) %>%
rename(CNTRY_NAME = country_name)
trade_mapping <- trade_percent_gdp %>%
filter(date == 2015) %>%
rename(CNTRY_NAME = country_name)
################# Modifying Polygon Shapefiles #################
# I then merged these counts with my polygon data. Leaflet throws an error if
# the variable column includes NA values, so I replaced all NA values.
basins_geometry@data <- left_join(basins_geometry@data, events_n, by = "NAME") %>%
left_join(treaties_n, by = "NAME")
# %>% left_join(orgs_n, by = "NAME")
# Same approach for countries.
countries_geometry@data <- left_join(countries_geometry@data, gdp_mapping, by = "CNTRY_NAME") %>%
left_join(pop_mapping, by = "CNTRY_NAME") %>%
left_join(trade_mapping, by = "CNTRY_NAME")
################# Creating Leaflet Map #################
# Set my color palettes for each variable.
binpal_num_events <- colorBin("Blues", basins_geometry$num_events, 5, pretty = FALSE, na.color = "#DFDFDF")
binpal_num_treaties <- colorBin("Greens", basins_geometry$num_treaties, 5, pretty = FALSE, na.color = "#DFDFDF")
binpal_num_orgs <- colorBin("Yellows", basins_geometry$num_orgs, 5, pretty = FALSE, na.color = "#DFDFDF")
binpal_gdp <- colorBin("Reds", countries_geometry$gdp, 5, pretty = FALSE, na.color = "#DFDFDF")
binpal_pop <- colorBin("Purples", countries_geometry$pop, 5, pretty = FALSE, na.color = "#DFDFDF")
binpal_trade <- colorBin("Oranges", countries_geometry$trade_percent_gdp, 5, pretty = FALSE, na.color = "#DFDFDF")
# Created my Leaflet map, using a simple CartoDB basemap. Zoomed out and
# centered the map, added my polygons, and changed their color based on their
# relative number of events. Added a layer toggle by grouping polygons and their
# respective legends.
leaflet(width = "100%") %>%
addProviderTiles(providers$CartoDB.Positron) %>%
setView(lng = 0, lat = 30,zoom = 1.5) %>%
## Conflict Events ##
addPolygons(data = basins_geometry,
stroke = FALSE,
smoothFactor = 0.2,
fillOpacity = .6,
popup= paste("Name:",
basins_geometry$NAME,
"Basin <br>",
"Number of Violent Conflicts:",
basins_geometry$num_events),
color = ~binpal_num_events(num_events),
group = "Conflict Events"
) %>%
addLegend("bottomright",
pal = binpal_num_events,
values = basins_geometry$num_events,
title = "# of water conflict <br> events since 1948",
opacity = 1,
labFormat = labelFormat(digits = 0),
group = "Conflict Events"
) %>%
## Treaties ##
addPolygons(data = basins_geometry,
stroke = FALSE,
smoothFactor = 0.2,
fillOpacity = .6,
popup= paste("Name:",
basins_geometry$NAME,
"Basin <br>",
"Number of Treaties:",
basins_geometry$num_treaties),
color = ~binpal_num_treaties(num_treaties),
group = "Treaties"
) %>%
addLegend("bottomright",
pal = binpal_num_treaties,
values = basins_geometry$num_treaties,
title = "# of treaties <br> since 1948",
opacity = 1,
labFormat = labelFormat(digits = 0),
group = "Treaties"
) %>%
## Organizations ##
# addPolygons(data = basins_geometry,
# stroke = FALSE,
# smoothFactor = 0.2,
# fillOpacity = .6,
# popup= paste("Name:",
# basins_geometry$NAME,
# "Basin <br>",
# "Number of Organizations:",
# basins_geometry$num_orgs),
# color = ~binpal_num_orgs(num_orgs),
# group = "Organizations"
# ) %>%
# addLegend("bottomright",
# pal = binpal_num_orgs,
# values = basins_geometry$num_orgs,
# title = "# of Organizations",
# opacity = 1,
# labFormat = labelFormat(digits = 0),
# group = "Organizations"
# ) %>%
## GDP ##
addPolygons(data = countries_geometry,
stroke = FALSE,
smoothFactor = 0.2,
fillOpacity = .6,
color = ~binpal_gdp(gdp),
group = "GDP (2015)"
) %>%
addLegend("bottomleft",
pal = binpal_gdp,
values = countries_geometry$gdp,
title = "2015 GDP",
opacity = 1,
labFormat = labelFormat(digits = 0),
group = "GDP (2015)"
) %>%
## Pop ##
addPolygons(data = countries_geometry,
stroke = FALSE,
smoothFactor = 0.2,
fillOpacity = .6,
color = ~binpal_pop(pop),
group = "Population (2015)"
) %>%
addLegend("bottomleft",
pal = binpal_pop,
values = countries_geometry$pop,
title = "2015 Population",
opacity = 1,
labFormat = labelFormat(digits = 0),
group = "Population (2015)"
) %>%
## Trade ##
addPolygons(data = countries_geometry,
stroke = FALSE,
smoothFactor = 0.2,
fillOpacity = .6,
color = ~binpal_trade(trade_percent_gdp),
group = "Trade % GDP (2015)"
) %>%
addLegend("bottomleft",
pal = binpal_trade,
values = countries_geometry$gdp_percent_trade,
title = "GDP Percent Trade",
opacity = 1,
labFormat = labelFormat(digits = 0),
group = "Trade % GDP (2015)"
) %>%
## Countries ##
addPolygons(data = countries_geometry,
stroke = TRUE,
color = "black",
weight = .4,
label = countries_geometry$CNTRY_NAME,
fill = FALSE,
smoothFactor = 0.2,
group = "Countries"
) %>%
## Layer Control ##
addLayersControl(overlayGroups = c("Countries", "Conflict Events", "Treaties", "Population (2015)", "GDP (2015)", "Trade % GDP (2015)"),
options = layersControlOptions(collapsed = TRUE)
) %>%
hideGroup(c("Treaties", "Population (2015)", "GDP (2015)", "Trade % GDP (2015)"))